package com.hmjk.health.setting.system;

import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageButton;

import com.hmjk.health.R;
import com.hmjk.health.background.HttpConf;

public class UserManualActivity extends Activity implements OnClickListener{
	private WebView webview = null;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
	
		setContentView(R.layout.usermanual);
		ImageButton back = (ImageButton) findViewById(R.id.back);
		back.setOnClickListener(this);
		
		webview = (WebView) findViewById(R.id.web);
		
		WebSettings wSet= webview.getSettings();
		wSet.setCacheMode(WebSettings.LOAD_NO_CACHE);
		//WebSettings wSet = webview.getSettings();    
		//wSet.setJavaScriptEnabled(false);
		//wSet.setDomStorageEnabled(false);
		String agreeUrl = HttpConf.getUserManualUri();
		webview.setWebViewClient(new WebViewClient(){

		      @Override
		      public boolean shouldOverrideUrlLoading(WebView view, String url) {
		        // TODO Auto-generated method stub
		        view.loadUrl(url);
		        return true;
		      }
		    });
		webview.loadUrl(agreeUrl);
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event){
	   	
	   	if(keyCode == KeyEvent.KEYCODE_BACK){
	   		webview.stopLoading();
			finish();
	   		return true;
	   		
	   	}
	   	return super.onKeyDown(keyCode,event);
    }
	
	@Override
	public void onClick(View v) {
		switch(v.getId()){
		case R.id.back:{
			webview.stopLoading();
			finish();
		}
		break;
		}
	}
}
